package com.willren;

import java.lang.reflect.Method;

import android.content.Context;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;

public class AvtAdvanced extends FrameActivity implements OnClickListener {
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.advanced);
	}

	@Override
	public void onClick(View v) {
		WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
		Method[] wmMethods = wifi.getClass().getDeclaredMethods();
		for (Method method : wmMethods) {
			Log.i("hot", method.toString());
			if (method.getName().equals("setWifiApEnabled")) {
				WifiConfiguration netConfig = new WifiConfiguration();
				netConfig.SSID = "\"PROVAAP\"";
				netConfig.allowedAuthAlgorithms
						.set(WifiConfiguration.AuthAlgorithm.OPEN);
				netConfig.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
				netConfig.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
				netConfig.allowedKeyManagement
						.set(WifiConfiguration.KeyMgmt.WPA_PSK);
				netConfig.allowedPairwiseCiphers
						.set(WifiConfiguration.PairwiseCipher.CCMP);
				netConfig.allowedPairwiseCiphers
						.set(WifiConfiguration.PairwiseCipher.TKIP);
				netConfig.allowedGroupCiphers
						.set(WifiConfiguration.GroupCipher.CCMP);
				netConfig.allowedGroupCiphers
						.set(WifiConfiguration.GroupCipher.TKIP);

				try {
					//method.invoke(wifi, netConfig, true);
					//break;
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
	}
}